package com.zhuiyun.educations.api.order.controller;

import com.zhuiyun.educations.api.order.entity.Order;
import com.zhuiyun.educations.api.order.service.OrderService;
import com.zhuiyun.educations.common.response.CommonResult;
import com.zhuiyun.educations.util.pageUtil.PageRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @ClassName OrderController
 * @Description TODO 订单管理
 * @Author ys
 * @Date 2023/6/19 19:47
 **/
@Slf4j
@RestController
@Api(tags = "订单管理")
@RequestMapping("/order")
public class OrderController {

    @Resource
    private OrderService orderService;
    /**
     * @Author ys
     * @Description TODO 分页查询
     * @Date 2023/6/26 14:09
     * @Return CommonResult
     * @param
     */
    @GetMapping("/getFilePrice")
    @ApiOperation(value = "课程价钱的分页查询方法")
    public CommonResult getFilePrice(PageRequest pageRequest){
        log.info("分页查询");
        return orderService.getFilePrice(pageRequest);
    }
    /**
     * @Author ys
     * @Description TODO 单查
     * @Date 2023/6/26 14:09
     * @Return CommonResult
     * @param
     */
    @GetMapping("/getFilePriceById")
    @ApiOperation(value = "课程价钱的分页查询方法")
    public CommonResult getFilePriceById(Integer courseId, Integer userId){
        log.info("分页查询");
        return orderService.getFilePriceById(courseId,userId);
    }
    /**
     * @Author ys
     * @Description TODO 单查
     * @Date 2023/6/26 14:09
     * @Return CommonResult
     * @param
     */
    @GetMapping("/getorderById")
    @ApiOperation(value = "课程价钱的分页查询方法")
    public CommonResult getorderById(Integer courseId, Integer userId){
        log.info("分页查询");
        return orderService.getorderById(courseId,userId);
    }

    /**
    * @Author cjl
    * @Description TODO 前端查询用户订单
    * @Date 2023/7/5 17:25
    * @Return com.zhuiyun.educations.common.response.CommonResult
    * @param userId
    * @param orderState
    */
    @GetMapping("/selectOrderEntityDTO")
    CommonResult selectOrderEntityDTO (Integer userId, Integer orderState){
        return orderService.selectOrderEntityDTO(userId,orderState);
    }
    @PostMapping("/add")
    public CommonResult add(Order order) {
        return orderService.add(order);
    }
    @PostMapping("/update")
    public CommonResult update(Integer id) {
        return orderService.update(id);
    }
    @PostMapping("/updatestate")
    public CommonResult updatestate(Integer id) {
        return orderService.updatestate(id);
    }
}
